<?php
/*******************************************************
* Process.php                                          *
*------------------------------------------------------*
* Majoris CMS (Content Management System)              *
*------------------------------------------------------*
* Licensed under the New BSD License, see license.txt  *
*------------------------------------------------------*
* Copyright 2011, Majoris CMS - All Rights Reserved    *
*******************************************************/

if (!defined('MajorisCMS') && !defined('Majoris__Installation'))
	die ('Mace Windu - "I don\'t think so"');

// Did we complete the installation yet?
if (file_exists($path . '/configure.php'))
{
	// If we didn't complete the installation, redirect.
	if (!isset($installed) || $installed != true)
		redirect($url . '/configure.php');
	// Otherwise, throw it away!
	else
		unlink('configure.php');
}

function redirect($location = '', $refresh = '')
{
	global $url;
	if (!empty($refresh))
	{
		header('Refresh: 0; URL=' . strtr($location, array(' ' => '%20')));
	}
	else
	{
		if (empty($location))
			$location = $url;
		header('Location: ' . str_replace(' ', '%20', $location));
	}
}

function callTemplate($template)
{
	if (!empty($template))
	{
		global $templatedir;
		if (file_exists($templatedir . '/' . $template . '-Template.php'))
			require_once($templatedir . '/' . $template . '-Template.php');
		else
			trigger_error('Sorry, the template "' . $template . '" cannot be loaded.');
	}
	else
		return;
}

?>